package com.ps.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ps.service.IItemService;
import com.ps.vo.Item;
import com.ps.vo.PageUtil;

@Controller
public class ItemController {

	@Autowired
	IItemService itemService;
	
	@GetMapping("/queryItemList")
	@ResponseBody
	public PageUtil<Item> queryItemList(@RequestParam int pageSize,@RequestParam int currentPage) {
		System.out.println("queryItemList进来了..."+pageSize+"  "+currentPage);
		PageUtil<Item> pageUtil=new PageUtil<>();
		pageUtil.setPageSize(pageSize);
		pageUtil.setCurrentPage(currentPage);
		pageUtil=itemService.queryItemList(pageUtil);
		pageUtil.getRows().forEach(System.out::println);
		return pageUtil;
	}
	
	@GetMapping("/deleteItemById")
	public void deleteItemById(@RequestParam int id) {
		System.out.println("deleteItemById进来了..."+id);
		itemService.deleteItemById(id);
	}
}
